<?php
	session_start();
	require_once('../includes/user.php');
	$user=new User();
	$date=date('Y-m-d');
$result_res=$user->query("select * from quiz_names where result=0 AND from_date <= '$date' AND result=0 AND profile_id='$_SESSION[id]'");
if($_SESSION['role']==8)
{
	$result_res=$user->query("select * from quiz_names where result=0 AND from_date <= '$date' AND result=0 ");
}
?>
<table width="637" border="0" align="center" cellpadding="0" cellspacing="0">
<?php
	if(mysql_num_rows($result_res)>0)
	{
?>
  <tr>
    <td align="center" valign="middle" class="head">Quiz name</td>
    <td align="center" valign="middle" class="head">Date</td>
    <td align="center" valign="middle" class="head">Students attended</td>
    <td align="center" valign="middle" class="head">Quiz for </td>
    <td align="center" valign="middle" class="head">Get Result</td>
  </tr>
  <tr>
    <td width="22%" align="center" valign="middle" class="head">&nbsp;</td>
    <td width="19%" align="center" valign="middle" class="head">&nbsp;</td>
    <td width="19%" align="center" valign="middle" class="head">&nbsp;</td>
    <td width="17%" align="center" valign="middle">&nbsp;</td>
    <td width="12%" align="center" valign="middle">&nbsp;</td>
  </tr>
  <?php
	while($result_row=mysql_fetch_array($result_res))
	{
	?>
  <tr>
    <td align="center" valign="middle"><?php echo $result_row['quiz_name']; ?></td>
    <td align="center" valign="middle"><?php
			$da=explode("-",$result_row['to_date']);
	echo $da[2].'/'.$da[1].'/'.$da[0];
	 ?></td>
    <td align="center" valign="middle"><?php
		$his_res=$user->query("select * from quiz_history where quiz_id='$result_row[quiz_id]'");
		echo mysql_num_rows($his_res);
		if($result_row['year_id']!=0)
		{
			$att_res=$user->query("select * from user_profile where accept=1 AND block=0 AND year='$result_row[year_id]' AND role=1");
		}
		else
		{
			$att_res=$user->query("select * from user_profile where accept=1 AND block=0 AND role=1");
		}
		echo ' Out of ';
		echo mysql_num_rows($att_res);
	 ?></td>
    <td align="center" valign="middle"><?php
	if($result_row['year_id']!=0)
	{
		echo $user->getYear($result_row['year_id']).' Only';
	}
	else
	{
		echo 'All Students';
	}
	 ?></td>
    <td align="center" valign="middle"><input type="image" src="img/buttons/b_props.png" onclick="getResults(<?php echo $result_row['quiz_id'];  ?>)" /></td>
  </tr>
  <tr>
    <td align="center" valign="middle">&nbsp;</td>
    <td align="center" valign="middle">&nbsp;</td>
    <td align="center" valign="middle">&nbsp;</td>
    <td align="center" valign="middle">&nbsp;</td>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
  <?php
	}
?>
<tr>
    <td colspan="5" align="right" valign="middle">&nbsp;</td>
  </tr>
  <?php
  	}
	else
	{
  ?>
  <div align="center">There are no pending Results</div>
  <?php } ?>
</table>
